<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
class User_favor_m extends CI_Model{
    function __construct() {
        parent::__construct();
        $this->load->database();
    }
    
    function insert($arr){
        $this->db->insert('user_favor',$arr);
    }
    
    function update($id,$arr){
        $this->db->where('id',$id);
        $this->db->update('user_favor',$arr);
    }
    
    function delete($userid,$subjectid){
        $arr=array('userid'=>$userid,'subjectid'=>$subjectid);
        $this->db->where($arr);
        $this->db->delete('user_favor');
    }
    
    function select($uid){
        $this->db->where('userid',$uid);
        $this->db->select('*');
        $this->db->join('user_favor','user_favor.subjectid=subject.id','inner');
        $query=$this->db->get('subject');
        return $query->result();
    }
}

